{extend name="layout/layout" /}
<!--请在下方写此页面body相关内容-->
{block name="container"}
<article class="page-container">
    <form class="form form-horizontal" id="form-admin-add" method="post" >
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员账号：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="" placeholder="请输入账号" id="username" name="username">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号密码：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="password" class="input-text" autocomplete="off" value="" placeholder="请输入密码" id="password" name="password">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="password" class="input-text" autocomplete="off" placeholder="请确认密码" id="repassword" name="repassword">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户组：</label>
            <div class="formControls col-xs-8 col-sm-8"><span class="select-box">
                <select class="select" name="group_id" size="1">
                    <?php foreach($group as $v){ if(empty($v['deep']) || $v['deep'] == 0){ ?>
                    <option value="<?php echo $v['id']?>" <?php echo $v['id'] == $info['pid'] ?'selected' : '' ?>><?php echo $v['group_name']?></option>
                    <?php } if(!empty($v['deep']) && $v['deep'] == 1){ ?>
                    <option value="<?php echo $v['id']?>" <?php echo $v['id'] == $info['pid'] ?'selected' : '' ?>><?php echo str_repeat('&nbsp', 4).'-'.$v['group_name'];?></option>
                    <?php } }?>
                </select>
			</span></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-8 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
{/block}
<!--请在上方写此页面body相关内容-->

<!--请在下方写此页面业务相关的脚本-->
{block name="js"}
<script type="text/javascript">
$(function(){
    $('.skin-minimal input').iCheck({
        checkboxClass: 'icheckbox-blue',
        radioClass: 'iradio-blue',
        increaseArea: '20%'
    });

    $("#form-admin-add").validate({
        rules:{
            username:{required:true, minlength:2, maxlength:20},
            password:{required:true, minlength:6, maxlength:18},
            repassword:{required:true, equalTo: "#password"},
            group_id:{required:true,}
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            var options = {
                beforeSubmit: function () {
                    load = layer.load();
                },
                success: function(obj){
                    if(obj.code !== 0){
                        layer.msg(obj.msg,{ icon:5, time:2000 });
                    } else {
                        layer.msg(obj.msg, { icon: 1, time: 1000 }, function(){
                            closeWindow();
                        });
                    }
                    layer.close(load);
                }
            };
            $(form).ajaxSubmit(options);
        }
    });
});
</script>
{/block}
<!--/请在上方写此页面业务相关的脚本-->